package com.dgut.controller;

import com.dgut.domain.Account;
import com.dgut.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class AccountController {

    @Autowired
    IAccountService service;

    @RequestMapping("/findAll")
    public ModelAndView findAll(){
        List<Account> accounts = service.findAccounts();
        ModelAndView mv = new ModelAndView();
        mv.setViewName("list");
        mv.addObject("accounts",accounts);
        return mv;
    }
}
